﻿// owner 蒋家伟

#include "Dbg_Warn_Define_Utils.h"

// qt
#include <QDebug>

// jsdk
#include "Dbg_Warn_Dlg.h"
#include "StringUtils.h"
#include "Log.h"
#include "ListenApplicationEventHandler.h"

using namespace jsdk;

void jsdk::Dbg_Warn_Define_Utils::show(const std::string & filePath, const std::string & function, const uint32_t rowNumber, const std::wstring & ownerName, const std::wstring & time, const std::wstring & description)
{
#ifdef _DEBUG
    //qDebug() << "**************Normal_Start**************";
    //qDebug() << QString::fromStdWString(L"FilePath    : " + StringUtils::ToWString(filePath));
    //qDebug() << QString::fromStdWString(L"Function    : " + StringUtils::ToWString(function));
    //qDebug() << QString::fromStdWString(L"RowNumber   : " + std::to_wstring(rowNumber));
    //qDebug() << QString::fromStdWString(L"OwnerName   : " + ownerName);
    //qDebug() << QString::fromStdWString(L"Time        : " + time);
    //qDebug() << QString::fromStdWString(L"Description : " + description);
    //qDebug() << "***************Normal_End***************";
#else
    LOG_NORMAL_(StringUtils::toWString(function) + L"——" + description);
#endif // _DEBUG
}

void jsdk::Dbg_Warn_Define_Utils::showAbnormal(const std::string& filePath, const std::string& function, const uint32_t rowNumber, const std::wstring& ownerName, const std::wstring& time, const std::wstring& description)
{
#ifdef _DEBUG
    Dbg_Warn_Dlg* pDlg = ListenApplicationEventHandler::get();
    if (pDlg)
        pDlg->show(QString::fromStdString(filePath).toStdWString(), QString::fromStdString(function).toStdWString(), rowNumber, ownerName, time, description);
    else
    {
#ifdef _MSC_VER
        qDebug() << "**************Error_Start**************";
        qDebug() << QString::fromStdWString(L"FilePath    : " + StringUtils::toWString(filePath));
        qDebug() << QString::fromStdWString(L"Function    : " + StringUtils::toWString(function));
        qDebug() << QString::fromStdWString(L"RowNumber   : " + std::to_wstring(rowNumber));
        qDebug() << QString::fromStdWString(L"OwnerName   : " + ownerName);
        qDebug() << QString::fromStdWString(L"Time        : " + time);
        qDebug() << QString::fromStdWString(L"Description : " + description);
        qDebug() << "***************Error_End***************";
        //__debugbreak();
    }
#endif
#else
    LOG_ERROR_(StringUtils::toWString(function) + L"——" + description);
#endif // _DEBUG
}
